import { createStore } from 'vuex'
import store2 from './modules/store2'
export default createStore({
  state: {
    name1: '张三'
  },
  getters: {
    getName (state) {
      return state.name1 + '!!!'
    }
  },
  mutations: {
    changeName (state, data) {
      state.name1 = data
    }
  },
  actions: {
    fetchMsg (context, val) {
      console.log('context: ', context);
      console.log('val: ', val);
      // 模拟ajax请求
      setTimeout(() => {
        context.commit('changeName', val)
      }, 1000)
    }
  },
  modules: {
    store2
  }
})
